package com.ozo.boot.gen.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ozo.boot.common.database.constant.DbConstant;
import com.ozo.boot.gen.entity.GenProject;
import com.ozo.boot.gen.mapper.GenProjectMapper;
import com.ozo.boot.gen.pojo.dto.GenProjectSaveDTO;
import com.ozo.boot.gen.service.IGenProjectService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 项目配置 服务实现类
 * </p>
 *
 * @author qiangesoft
 * @since 2024-11-12
 */
@Service
public class GenProjectServiceImpl extends ServiceImpl<GenProjectMapper, GenProject> implements IGenProjectService {

    @Override
    public void add(GenProjectSaveDTO saveDTO) {
        GenProject genProject = BeanUtil.copyProperties(saveDTO, GenProject.class);
        baseMapper.insert(genProject);
    }

    @Override
    public void edit(GenProjectSaveDTO saveDTO) {
        GenProject genProject = BeanUtil.copyProperties(saveDTO, GenProject.class);
        baseMapper.updateById(genProject);
    }

    @Override
    public GenProject get() {
        LambdaQueryWrapper<GenProject> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.last(DbConstant.LIMIT_1);
        return baseMapper.selectOne(queryWrapper);
    }

}
